package com.cr.bio.class2;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class BIOClient implements Runnable{
    private String address;
    private int port;

    public BIOClient(String address, int port) {
        this.address = address;
        this.port = port;
    }

    public static void main(String[] args) {
        BIOClient client=new BIOClient("localhost",2020);
        client.run();
    }
    @Override
    public void run() {
        try(Socket socket=new Socket(address,port);
            OutputStream outputStream=socket.getOutputStream()){
            Scanner scanner=new Scanner(System.in);
            String msg=scanner.nextLine();
            outputStream.write(msg.getBytes("UTF-8"));
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
